package com.atguigu.yygh.common.utils;



import com.atguigu.yygh.common.helper.JwtHelper;
import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.HttpServletRequest;

@Slf4j
public class AuthContextHolder {
    /**
     * 获取用户ID 实名认证
     * @param request
     * @return
     */
    public static Long getUserId(HttpServletRequest request){
        //头中获取token 用于判断用户是否登录状态
        String token = request.getHeader("token");
        Long userId = JwtHelper.getUserId(token);
        return userId;
    }

    /**
     * 获取用户姓名 实名认证
     * @param request
     * @return
     */
    public static  String getUserName(HttpServletRequest request){
        //头中获取token 用于判断用户是否登录状态
        String token = request.getHeader("token");
        String userName = JwtHelper.getUserName(token);
        return userName;
    }
}
